﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using UniversityStudentManagemnetSystem.DAO.DAL;
using UniversityStudentManagemnetSystem.DAO.DAL.Gateway;

namespace UniversityStudentManagemnetSystem.BLL
{
    public class DepartmentManager
    {
        DepartmentGateway departmentGateway = new DepartmentGateway();
        public bool DepartmentSave(Department department)
        {
            
           if (departmentGateway.HasThisDepartmentCode(department.Code) && departmentGateway.HasThisDepartmentName(department.Name))
            {
                throw new Exception("This Code and Name already Exist. Please try again.");
            }
            else if(departmentGateway.HasThisDepartmentCode(department.Code))
            {
                throw new Exception("This Code already Exit. Please try again.");
            }
            else if (departmentGateway.HasThisDepartmentName(department.Name))
            {
                throw new Exception("This Name already Exit. Please try again.");
            }
            else 
            {
                return departmentGateway.Save(department);
            }
        }
        public DataTable GetDepartments()
        {
            return departmentGateway.GetDepartments();
        }
        public DataTable GetAllDepartments()
        {
            return departmentGateway.GetAllDepartments();
        }

    }
}